#include "BlueprintScriptLibrary/ScriptLibrary.h"
#include "BlueprintScriptLibrary/VariableEntity.h"
namespace BlueprintScriptLibrary
{
    BlueprintScriptLibrary::NativeMethodPin* ConstructGetMethod() {
        std::function<BlueprintScriptLibrary::Var* (SingleVaribleEntity*)> f = std::bind(&SingleVaribleEntity::Get, std::placeholders::_1);
        BlueprintScriptLibrary::NativeMethodPin* fp = NewObj<NativeMethodPin>();//new BlueprintScriptLibrary::NativeMethodPin;
        std::vector<BlueprintScriptLibrary::Var*> vbs;
        BlueprintScriptLibrary::Array<BlueprintScriptLibrary::Var> inputArray(0);
        BlueprintScriptLibrary::Array<BlueprintScriptLibrary::Var> outputArray(1);
        std::function<BlueprintScriptLibrary::Var** (BlueprintScriptLibrary::Object*, BlueprintScriptLibrary::Var**)> func = [f](BlueprintScriptLibrary::Object* obj, BlueprintScriptLibrary::Var** input)->BlueprintScriptLibrary::Var** {
            SingleVaribleEntity* mc = dynamic_cast<SingleVaribleEntity*>(obj);
            BlueprintScriptLibrary::Array<BlueprintScriptLibrary::Var> outputArray(1, false);
            BlueprintScriptLibrary::Var* outRes = NewObj< BlueprintScriptLibrary::Var>();
            outRes = f(mc);
            outputArray.data[0] = (BlueprintScriptLibrary::Var*)outRes;
            return outputArray.data;
            };
        fp->Init("Get", inputArray.data, outputArray.data, func);
        return fp;
    }
    Class* SingleVaribleEntity::GetClass()
    {
        Array<NativeMembers> arrMember;
        Array<MethodPin> arrMethod(1, false);
        arrMethod.data[0] = ConstructGetMethod();
        return  Class::BuildClassFromArray("SingleVaribleEntity", arrMember, arrMethod);
    }
    BlueprintScriptLibrary::NativeMethodPin* ConstructAddMethod() {
        std::function<void(ArrayVaribleEntity*, BlueprintScriptLibrary::Var*)> f = std::bind(&ArrayVaribleEntity::Add, std::placeholders::_1, std::placeholders::_2);
        BlueprintScriptLibrary::NativeMethodPin* fp = new BlueprintScriptLibrary::NativeMethodPin;
        std::vector<BlueprintScriptLibrary::Var*> vbs;
        BlueprintScriptLibrary::Array<BlueprintScriptLibrary::Var> inputArray(1);
        BlueprintScriptLibrary::Array<BlueprintScriptLibrary::Var> outputArray(1);
        std::function<BlueprintScriptLibrary::Var** (BlueprintScriptLibrary::Object*, BlueprintScriptLibrary::Var**)> func = [f](BlueprintScriptLibrary::Object* obj, BlueprintScriptLibrary::Var** input)->BlueprintScriptLibrary::Var** {
            ArrayVaribleEntity* mc = dynamic_cast<ArrayVaribleEntity*>(obj);
            BlueprintScriptLibrary::Var* input0 = dynamic_cast<BlueprintScriptLibrary::Var*>(input[0]);
            f(mc, input0);
            return nullptr;
            };
        fp->Init("Add", inputArray.data, outputArray.data, func);
        return fp;
    }



    Class* ArrayVaribleEntity::GetClass()
    {
        Array<NativeMembers> arrMember;
        Array<NativeMethodPin> arrMethod(1, false);
        arrMethod.data[0] = ConstructGetMethod();
        return  Class::BuildClass("", arrMember.data, arrMethod.data);
    }

    Class* MapVaribleEntity::GetClass()
    {
        return nullptr;
    }
}